package gmu.xytxl.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBUtil {
	private static Connection conn=null;
	private static String URL = DBConfig.DB_URL;
	private static String USER = DBConfig.DB_USER;
	private static String PASSWORD = DBConfig.DB_PWD;
	private static String DRIVER = DBConfig.DB_DRIVER;
	 static{
	        try {
	        	 System.out.println(DRIVER);
		            System.out.println(USER);
		            System.out.println(PASSWORD);
	            //1.加载驱动程序
	            Class.forName(DRIVER);
	            //2.获得数据库的连接
	            conn=(Connection)DriverManager.getConnection(URL,USER,PASSWORD);
	            
	        } catch (ClassNotFoundException e) {
	        	System.out.println("连接失败");
	            e.printStackTrace();
	        } catch (SQLException e) {
	            e.printStackTrace();
	        }
	    }
	 public Connection getConnection() {
		 return conn;
	 }
	 
	 
	 
	 public static void main(String[] args) {
		System.out.println(conn);
	}
}
